package org.eenie.kdassistant.hooker;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

/**
 * Created by Eenie on 2017/10/9.
 * Email: eeniework@gmail.com
 * Des:
 */

public class OneCloudHooker implements IXposedHookLoadPackage {

    private String PKG_NAME = "com.onething.minecloud";


    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam param) throws Throwable {
        if (!param.packageName.equals(PKG_NAME)) {
            return;
        }

        XposedBridge.log("hook success pkg = " + param.packageName);

        XposedHelpers.findAndHookMethod("com.onething.minecloud.coturn.a.b", param.classLoader, "a", String.class, new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                XposedBridge.log("encode before = " + param.args[0]);
                XposedBridge.log("encode after = " + param.getResult().toString());
            }
        });

        XposedHelpers.findAndHookMethod("com.onething.minecloud.util.t", param.classLoader, "a", String.class, new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                XposedBridge.log("encode before md5 = " + param.args[0]);
                XposedBridge.log("encode after md5 = " + param.getResult().toString());
            }
        });
    }
}
